import requests
from lxml import etree
try:

    response = requests.get("https://alpha.wallhaven.cc/search?q=&categories=001&purity=100&topRange=1M&sorting=toplist&order=desc&page={}".format(1))
except:
        print("网页访问有问题，请检查代码和网络")
response.encoding = "utf-8"
selector = etree.HTML(response.text)
img = selector.xpath('//img/@data-src')
for i in range(0,len(img)):
    img[i]
    print(img[i])
    response = requests.get (img[i])
    try:
       with open("imgimg{}.png".format(i),"wb+") as f:
        f.write(response.content)
    except:
        print("网页访问有问题，请检查代码和网络")
